package com.test.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;

import java.util.List;

public class ExcelMain {
    public static void main(String[] args) {
        ExcelReaderBuilder workBook = EasyExcel.read
                ("C:\\Users\\zhangdan\\Documents\\WXWork\\1688858289301344\\Cache\\File\\2022-02\\减积分群发模板(1).csv", Points.class, new PointReadListener());

// 封装工作表
        ExcelReaderSheetBuilder sheet1 = workBook.sheet();
// 读取
        sheet1.doRead();

//写入数据库
        List<Points> pointList = PointReadListener.getStudentList();
        int customerPoint = 0;
        for (Points point : pointList) {
            customerPoint = point.getPoint();
            if (customerPoint > 9900) {
                for (int i = 9900; i < customerPoint; customerPoint = customerPoint - i) {
                    System.out.println(point.getOptType() + "\t" + point.getCustomerNo() + "\t" + i);
                }
            } else {
                System.out.println(point.getOptType() + "\t" + point.getCustomerNo() + "\t" + customerPoint);
            }
        }
    }


}
